package org.jeie.actions;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

import org.jeie.main.Action;
import org.jeie.messages.Messages;

public class NewImageAction implements Action {
	public Dimension d;
	public Color color;

	public NewImageAction(Dimension d, Color color) {
		this.d = d;
		this.color = color;
	}

	public String getName() {
		return Messages.getString("Action.NewImage"); //$NON-NLS-1$
	}

	public BufferedImage apply(BufferedImage img) {
		BufferedImage newIMG = new BufferedImage(
			d.width,
			d.height,
			BufferedImage.TYPE_INT_ARGB);
		Graphics g = newIMG.createGraphics();
		g.setColor(color);
		g.fillRect(0, 0, d.width, d.height);
		g.dispose();
		return newIMG;
	}
}
